﻿
using System;
using System.Collections.Generic;
using System.Text;
using Mang24k99.Model.CLMN;
using NHibernate;
using NHibernate.Expression;
using Castle.ActiveRecord.Queries;
using AjaxPro;
namespace Mang24k99.Business.CLMN
{
    public partial class BKtClmnNewstrastar
    {

        public static IList<MKtClmnNewstrastar> FindAllBySpellChines(string spell)
        {
            ICriterion[] criteria = new ICriterion[]
            {
                Expression.Eq("IsValidate",1),
                Expression.Like("SpellChines",spell,MatchMode.Start),
            };
            //return MKtClmnNewstrastar.SelectALLSliced(0, 6, criteria);
            return MKtClmnNewstrastar.SelectAll(criteria);
        }

        [AjaxMethod]
        public string GetSpellChines(string spell, string objtxt, string objtxtSource)
        {
            StringBuilder stringBuilderReturn = new StringBuilder();
            stringBuilderReturn.Append("<table id=\"searchTable\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" align=\"center\"  bordercolor=\"#BED6A6\"");
            stringBuilderReturn.Append("style=\"border-collapse: collapse\">");
            try
            {
                IList<MKtClmnNewstrastar> models = FindAllBySpellChines(spell);
                foreach (MKtClmnNewstrastar model in models)
                {
                    string id = model.ColumnID.ToString();
                    string name = model.ColumnName;
                    stringBuilderReturn.Append("<tr>");
                    stringBuilderReturn.Append("<td class=\"tb_txt2\"  nowrap=\"nowrap\" style=\"cursor:pointer;\" title=\"" + id + "\" onclick=\"SearchStockHide('" + objtxt + "',this.innerHTML,'" + objtxtSource + "',this.title)\">");
                    stringBuilderReturn.Append("" + name + "</td>");
                    stringBuilderReturn.Append("</tr>");
                }
                if (models.Count==0)
                {
                    string id = "0";
                    string name = "没有结果";
                    stringBuilderReturn.Append("<tr>");
                    stringBuilderReturn.Append("<td class=\"tb_txt2\"  nowrap=\"nowrap\" style=\"cursor:pointer;\" title=\"" + id + "\" onclick=\"SearchStockHide('" +  "',this.innerHTML,'" +  "',this.title)\">");
                    stringBuilderReturn.Append("" + name + "</td>");
                    stringBuilderReturn.Append("</tr>");
                }
            }
            catch (System.Exception e)
            {

            }

            stringBuilderReturn.Append("</table>");

            return stringBuilderReturn.ToString();
        }
    }
}
